package com.sc.controller;

import com.sc.common.pojo.CommonResult;
import com.sc.common.pojo.EasyUiDataGridResult;
import com.sc.common.pojo.EasyUiTreeNode;
import com.sc.service.ContentCategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * Created by sc on 2017/10/19.
 */
@Controller
@RequestMapping("/content/category")
public class ContentCatController {

    @Autowired
    private ContentCategoryService contentCategoryService;

    @RequestMapping("/list")
    @ResponseBody
    public List<EasyUiTreeNode> getList(@RequestParam(value = "id",defaultValue = "0") Long parentId){
        return contentCategoryService.getList(parentId);
    }

    @RequestMapping(value = "/update",method = RequestMethod.POST)
    @ResponseBody
    public CommonResult updateNode(Long id, String name){
        return contentCategoryService.updateNode(id,name);
    }
    @RequestMapping(value = "/create",method = RequestMethod.POST)
    @ResponseBody
    public CommonResult createNode(Long parentId,String name){
        return contentCategoryService.createNode(parentId,name);
    }

    @RequestMapping(value = "/delete",method = RequestMethod.POST)
    @ResponseBody
    public void deleteNode(Long id,Long parentId){
        contentCategoryService.deleteNode(id,parentId);
    }

}
